#include <kuai/misc/strtool.hpp>
#include <kuai/mol/space.hpp>

#ifndef _KUAI_SIM_REPORTER_
#define _KUAI_SIM_REPORTER_

namespace kuai {

	class SpaceReporter
		: public SpaceWorker 
	{
	public:
		enum {
			DUMP_NOTHING,
			DUMP_SUMMER,
			DUMP_DETAIL,
			DUMP_EVERYTHING,
		};
		SpaceReporter();

		virtual void set(const String& key, const String& data);
		virtual String get(const String& key) const;

	protected:
		FileName filename;
		std::ostream* pout;
		std::ofstream fout;

		Index dumpLevel;
	};

	class CountAngleDistribution
		: public SpaceReporter
	{
	public:
		DECLARE_WORKER_CREATOR(CountAngleDistribution)

		CountAngleDistribution();

		virtual void set(const String& key, const String& data);
		virtual String get(const String& key) const;
		
		void start(std::ostream& stdlog, std::ostream& errlog, PhaseSpace& space, EnergySet& efunc, Index tid=0, Index nThreads=1);
		void finish(std::ostream& stdlog, std::ostream& errlog, PhaseSpace& space, EnergySet& efunc, Index tid=0, Index nThreads=1);
		void act(PhaseSpace& space, size_t iStep, EnergySet& efunc, Index tid=0, Index nThreads=1);

	protected:
		std::vector<std::pair<Index, Index> > pairs;
		XYZ axis;
		RealNumber slice;
		std::vector<size_t> count;
		const XYZ* coords;
		const PBC* pbc;
	};


}

#endif
